package com.wzh.main.copy;

import com.wzh.bean.Bean;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//Java中=的意义
		//复制 基本类型
		int a=5;
		int b=a;
		int c=a;
		System.out.println(a+" :a"+" b:"+b+" c:"+c);
		//进行改变a的值 看是否会影响bc的值
		a=10;
		System.out.println(a+" :a"+" b:"+b+" c:"+c);
		//改变bc 的值 看是否会影响a的值
		b=20;
		c=30;
		System.out.println(a+" :a"+" b:"+b+" c:"+c);
		//说明 基本类型是深拷贝 ？？？？
		
		//查看128以上的值
		int x=130;
		int y=x;
		int z=x;
		System.out.println(x+" :x"+" y:"+y+" z:"+z);
		x=133;
		System.out.println(x+" :x"+" y:"+y+" z:"+z);
		
		// 复制的类
		Bean bean1=new Bean();
		bean1.Nmae="wzh1";
		bean1.Password="psw1";
		bean1.age=23;
		
		Bean bean2=new Bean();
		bean2=bean1;
		System.out.println(bean1.toString());
		System.out.println(bean2.toString());
		//修改后
		bean2.age=32;
		bean2.Nmae="name";
		bean2.Password="password";
		System.out.println(bean1.toString());
		System.out.println(bean2.toString());
		//发现原数据进行了改变  说明 java 中= 是属于浅拷贝 只是指向 原来的地址
		System.out.println(bean1.hashCode());
		System.out.println(bean2.hashCode());
		System.out.println("深拷贝==========");
		//实现Java的深拷贝
		Bean bean3=bean1.clone();
		System.out.println(bean1.hashCode());
		System.out.println(bean3.hashCode());
		System.out.println(bean1.toString());
		System.out.println(bean3.toString());
		bean3.age=99;
		bean3.Nmae="www";
		System.out.println(bean1.toString());
		System.out.println(bean3.toString());
	}

}
